package com.fayou.cloud.cloudconsumeropenfeignorder8082.fallback;

import com.fayou.cloud.cloudconsumeropenfeignorder8082.service.FeignPaymentService;
import com.fayou.cloud.entites.CommonResult;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class FeignPaymentServiceFallbackFactory implements FallbackFactory<FeignPaymentService> {
    Logger logger = LoggerFactory.getLogger(FeignPaymentServiceFallbackFactory.class);

    @Override
    public FeignPaymentService create(Throwable throwable) {
        logger.info("------"+throwable.toString());
        return new FeignPaymentService() {

            @Override
            public CommonResult selectOne(Integer id) {
                return new CommonResult(404, "消息接口繁忙，请稍后重试！", null);
            }

            @Override
            public String paymentFeignTimeout() {
                return "消息接口繁忙，请稍后重试！";
            }

            @Override
            public String paymentInfo_OK(Integer id) {
                return "消息接口繁忙，请稍后重试！";
            }

            @Override
            public String paymentInfo_TimeOut(Integer id) {
                return "消息接口繁忙，请稍后重试！";
            }

            @Override
            public String paymentCircuitBreaker(Integer id) {
                return "消息接口繁忙，请稍后重试！";
            }
        };
    }
}
